package com.selftaught.common.exception.file;

import java.util.Arrays;

/**
 * 文件上传 误异常类
 *
 * @author admin
 */
public class InvalidExtensionException extends FileUploadException {

    private static final long serialVersionUID = 1L;

    /**
     * 允许上传文件后缀
     */
    private String[] allowedExtension;

    /**
     * 上传文件后缀
     */
    private String extension;

    /**
     * 文件名
     */
    private String fileName;

    public InvalidExtensionException(String[] allowedExtension, String extension, String fileName) {
        super("文件[" + fileName + "]后缀[" + extension + "]不正确，请上传" + Arrays.toString(allowedExtension) + "格式");
        this.allowedExtension = allowedExtension;
        this.extension = extension;
        this.fileName = fileName;
    }

    public String[] getAllowedExtension() {
        return allowedExtension;
    }

    public String getExtension() {
        return extension;
    }

    public String getFileName() {
        return fileName;
    }

    public static class InvalidImageExtensionException extends InvalidExtensionException {
        private static final long serialVersionUID = 1L;

        public InvalidImageExtensionException(String[] allowedExtension, String extension, String fileName) {
            super(allowedExtension, extension, fileName);
        }
    }

    public static class InvalidFlashExtensionException extends InvalidExtensionException {
        private static final long serialVersionUID = 1L;

        public InvalidFlashExtensionException(String[] allowedExtension, String extension, String fileName) {
            super(allowedExtension, extension, fileName);
        }
    }

    public static class InvalidMediaExtensionException extends InvalidExtensionException {
        private static final long serialVersionUID = 1L;

        public InvalidMediaExtensionException(String[] allowedExtension, String extension, String fileName) {
            super(allowedExtension, extension, fileName);
        }
    }

    public static class InvalidVideoExtensionException extends InvalidExtensionException {
        private static final long serialVersionUID = 1L;

        public InvalidVideoExtensionException(String[] allowedExtension, String extension, String fileName) {
            super(allowedExtension, extension, fileName);
        }
    }
}
